import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class test1 {
    public static void main(String[] args) {
        LinkedList<Integer>list=new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);

        System.out.println(list);
        System.out.println("====1====");
        for(int i=0;i<list.size();i++){
            System.out.print(list.get(i)+" ");
        }
        System.out.println();
        System.out.println("=====2=====");
        for (Integer n:list){
            System.out.print(n+" ");
        }
        System.out.println();
        System.out.println("=====3=====");
        List<Integer> sub=  list.subList(1,3);
        System.out.println(sub);
        ListIterator<Integer> dea= list.listIterator();
        while (dea.hasNext()){
            System.out.print(dea.next()+" ");
        }
        System.out.println();
        System.out.println("=====4=====");
        ListIterator<Integer> aed=list.listIterator(list.size());
        while (aed.hasPrevious()){
            System.out.print(aed.previous()+" ");
        }
    }
}
